<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

Route::get('login', 'LoginController@showLoginForm')->name('admin.login');
Route::post('login', 'LoginController@login');
Route::get('logout', 'LoginController@logout');
Route::post('logout', 'LoginController@logout');

Route::get('/', 'IndexController@index');


Route::get('index', ['as' => 'admin.index', 'uses' => function () {
    return redirect('/admin/log-viewer');
}]);


Route::group(['middleware' => ['auth:admin', 'menu', 'authAdmin']], function () {

    //权限管理路由
    Route::get('permission/{cid}/create', ['as' => 'admin.permission.create', 'uses' => 'PermissionController@create']);
    Route::get('permission/manage', ['as' => 'admin.permission.manage', 'uses' => 'PermissionController@index']);
    Route::get('permission/{cid?}', ['as' => 'admin.permission.index', 'uses' => 'PermissionController@index']);
    Route::post('permission/index', ['as' => 'admin.permission.index', 'uses' => 'PermissionController@index']); //查询
    Route::resource('permission', 'PermissionController', ['names' => ['update' => 'admin.permission.edit', 'store' => 'admin.permission.create']]);


    //角色管理路由
    Route::get('role/index', ['as' => 'admin.role.index', 'uses' => 'RoleController@index']);
    Route::post('role/index', ['as' => 'admin.role.index', 'uses' => 'RoleController@index']);
    Route::resource('role', 'RoleController', ['names' => ['update' => 'admin.role.edit', 'store' => 'admin.role.create']]);


    //用户管理路由
    Route::get('user/index', ['as' => 'admin.user.index', 'uses' => 'UserController@index']);  //用户管理
    Route::post('user/index', ['as' => 'admin.user.index', 'uses' => 'UserController@index']);
    Route::resource('user', 'UserController', ['names' => ['update' => 'admin.role.edit', 'store' => 'admin.role.create']]);

    //标签路由
    Route::get('tag/index', ['as' => 'admin.tag.index', 'uses' => 'TagController@index']);  //用户管理
    Route::post('tag/index', ['as' => 'admin.tag.index', 'uses' => 'TagController@index']);
    Route::resource('tag', 'TagController', ['names' => ['update' => 'admin.tag.edit', 'store' => 'admin.tag.create']]);

    //文章分类路由
    Route::get('category/{cid}/create', ['as' => 'admin.category.create', 'uses' => 'CategoryController@create']);
    Route::get('category/{id?}', ['as' => 'admin.category.index', 'uses' => 'CategoryController@index']);  //用户管理
    Route::post('category/index', ['as' => 'admin.category.index', 'uses' => 'CategoryController@index']);
    Route::resource('category', 'CategoryController', ['names' => ['update' => 'admin.CategoryController.edit', 'store' => 'admin.CategoryController.create']]);

    //文章管理路由
    Route::get('article/index',['as' => 'admin.article.index','uses' => 'ArticleController@index']);
    Route::post('article/index',['as' => 'admin.article.index','uses' => 'ArticleController@index']);
    Route::get('atlc/index',['as' => 'admin.atlc.index','uses' => 'ArticleController@create']);
    Route::resource('article','ArticleController',['names' => ['update' => 'admin.ArticleController.edit','store' => 'admin.ArticleController.create']]);

    //导航管理
    Route::get('navigation/index',['as' => 'admin.navigation.index','uses' => 'navigationController@index']);
    Route::post('navigation/index',['as' => 'admin.navigation.index','uses' => 'navigationController@index']);
    Route::get('navigation/setnav/{id}',['as' => 'admin.navigation.setnav','uses' => 'navigationController@setnav']);
    Route::resource('navigation', 'navigationController', ['names' => ['update' => 'admin.navigation.edit', 'store' => 'admin.navigation.create']]);
});

Route::get('/', function () {
    return redirect('/admin/index');
});
Route::get('test/index',['as' => 'admin.test.index','uses' => 'TestController@index']);

//Route::resource('tag','TagController');

